<script setup>
import { useRouter } from 'vue-router'
const router = useRouter()
const item = defineModel('item')
const handle = () => {
  //根据点击的商品进入商品详情
  router.push('/detail/' + item.value.id)
}
</script>
<template>
  <div class="box" @click="handle">
    <el-image class="img" :src="item?.picture" :fit="contain"></el-image>
    <div class="value">
      <h3>
        {{ item?.name }}
      </h3>
      <p>{{ item?.desc }}</p>
    </div>
  </div>
</template>
<style lang="scss" scoped>
.box {
  width: 250px;
  height: 100px;
  margin: 10px;
  display: flex;
  .img {
    width: 40%;
    height: 100%;
  }
  .value {
    background-color: #f7f4ed;
    height: 100%;
    border: 2px solid;
    border-color: rgba(151, 151, 151, 0.3);
    width: 100%;
    text-align: center;
  }
  :deep(h3:first-child) {
    margin-top: 12px;
  }
  :deep(h3) {
    font-size: 18px;
    font-weight: 1;
    font-family: '像素字体';
    margin: 0;
  }
  p {
    margin: 5px;
    font-size: 15px;
    color: #ddc871;
    font-family: '清松';
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
  }
}
.box:hover {
  animation: scale-up-center 0.1s cubic-bezier(0.39, 0.575, 0.565, 1) both;
}

@keyframes scale-up-center {
  0% {
    transform: scale(1);
  }
  100% {
    transform: scale(1.1);
  }
}
</style>